package de.ipk_gatersleben.bit.bi.edal.publication.listener;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JOptionPane;

import de.ipk_gatersleben.bit.bi.edal.publication.PropertyLoader;
import de.ipk_gatersleben.bit.bi.edal.publication.PublicationModul;

/**
 * {@link WindowAdapter} to ask for the user confirmation before closing a
 * window.
 * 
 * @author arendd
 * 
 */
public class ShutdownWindowsListener extends WindowAdapter {

	public ShutdownWindowsListener() {
		super();
	}

	public void windowClosing(WindowEvent e) {
		int result = JOptionPane.showConfirmDialog(PublicationModul.getFrame(),
				"Close " + PropertyLoader.PROGRAM_NAME + " ?", "EXIT",
				JOptionPane.YES_NO_OPTION);
		if (result == JOptionPane.YES_OPTION) {
			System.exit(0);
		}
	}

}